package org.example.pinda.event;

import lombok.AllArgsConstructor;
import org.example.pinda.entity.OperateLog;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;

import java.util.function.Consumer;

@AllArgsConstructor
public class SysLogListener {

    private Consumer<OperateLog> consumer;

    @Async
    @Order
    @EventListener(SysLogEvent.class)
    public void onEvent(SysLogEvent event) {
        OperateLog source = (OperateLog) event.getSource();
        consumer.accept(source);
    }

}
